import { defineStore } from "pinia";
export const useCounterStore = defineStore("counter", {
  state: () => ({
    imgPrefix: "https://img-tianchen.oss-cn-guangzhou.aliyuncs.com/",
    profile: JSON.parse(localStorage.getItem("profile")) || "",
    tempOb: JSON.parse(localStorage.getItem("tempOb")) || "",
    appKey: "8cc6875cc7678ac2f0ed1950d6fbc73e",
    mittOb: null,
    time: null,
    recordSt: 0,
    enroomInstance: null,
    NEAuthService: null,
    NERoomService: null,
    pkRoomContent: null,
    openOffMike: true,
    nimInstance: null,
    roomLiveInfo: null,
    pkRoomInfo: null,
    roomContent: null,
    roomLiveStreamInfo: null,
    isQuickReply: false,
    swithQuickShow: true,
    isOpenPKWin: false,
    richVal: "",
    allMsg: {},
    uidStr: [],
    mikeDefu: 1,
    isContrib:false,
    contribuInfo:null,
    leave1Arr: [
      {
        min: 0,
        max: 10,
        url: new URL("../assets/rich_leve1.png", import.meta.url).href,
        name: "一掷千金",
        level: "Lv1",
      },
      {
        min: 10,
        max: 30,
        url: new URL("../assets/rich_leve2.png", import.meta.url).href,
        name: "浅尝辄止",
        level: "Lv2",
      },
      {
        min: 30,
        max: 50,
        url: new URL("../assets/rich_leve3.png", import.meta.url).href,
        name: "小试牛刀",
        level: "Lv3",
      },
      {
        min: 50,
        max: 70,
        url: new URL("../assets/rich_leve4.png", import.meta.url).href,
        name: "略有小成",
        level: "Lv4",
      },
      {
        min: 70,
        max: 100,
        url: new URL("../assets/rich_leve5.png", import.meta.url).href,
        name: "积少成多",
        level: "Lv5",
      },
      {
        min: 100,
        max: 200,
        url: new URL("../assets/rich_leve6.png", import.meta.url).href,
        name: "崭露头角",
        level: "Lv6",
      },
      {
        min: 200,
        max: 400,
        url: new URL("../assets/rich_leve7.png", import.meta.url).href,
        name: "稳步前行",
        level: "Lv7",
      },
      {
        min: 400,
        max: 700,
        url: new URL("../assets/rich_leve8.png", import.meta.url).href,
        name: "崭露头角",
        level: "Lv8",
      },
      {
        min: 700,
        max: 900,
        url: new URL("../assets/rich_leve9.png", import.meta.url).href,
        name: "出手不凡",
        level: "Lv9",
      },
      {
        min: 900,
        max: 1200,
        url: new URL("../assets/rich_leve10.png", import.meta.url).href,
        name: "挥洒自如",
        level: "Lv10",
      },
      {
        min: 1200,
        max: 3000,
        url: new URL("../assets/rich_leve11.png", import.meta.url).href,
        name: "崭新局面",
        level: "Lv11",
      },
      {
        min: 3000,
        max: 5000,
        url: new URL("../assets/rich_leve12.png", import.meta.url).href,
        name: "厚积薄发",
        level: "Lv12",
      },

      {
        min: 5000,
        max: 7000,
        url: new URL("../assets/rich_leve13.png", import.meta.url).href,
        name: "一鸣惊人",
        level: "Lv13",
      },
      {
        min: 7000,
        max: 9000,
        url: new URL("../assets/rich_leve14.png", import.meta.url).href,
        name: "财大气粗",
        level: "Lv14",
      },
      {
        min: 9000,
        max: 12000,
        url: new URL("../assets/rich_leve15.png", import.meta.url).href,
        name: "出手阔绰",
        level: "Lv15",
      },
      {
        min: 12000,
        max: 20000,
        url: new URL("../assets/rich_leve16.png", import.meta.url).href,
        name: "风生水起",
        level: "Lv16",
      },
      {
        min: 20000,
        max: 25000,
        url: new URL("../assets/rich_leve17.png", import.meta.url).href,
        name: "如鱼得水",
        level: "Lv17",
      },
      {
        min: 25000,
        max: 30000,
        url: new URL("../assets/rich_leve18.png", import.meta.url).href,
        name: "左右逢源",
        level: "Lv18",
      },
      {
        min: 30000,
        max: 35000,
        url: new URL("../assets/rich_leve19.png", import.meta.url).href,
        name: "锦上添花",
        level: "Lv19",
      },
      {
        min: 35000,
        max: 40000,
        url: new URL("../assets/rich_leve20.png", import.meta.url).href,
        name: "气吞山河",
        level: "Lv20",
      },
      {
        min: 40000,
        max: 50000,
        url: new URL("../assets/rich_leve21.png", import.meta.url).href,
        name: "挥金如土",
        level: "Lv21",
      },
      {
        min: 50000,
        max: 60000,
        url: new URL("../assets/rich_leve22.png", import.meta.url).href,
        name: "八面威风",
        level: "Lv22",
      },
      {
        min: 60000,
        max: 70000,
        url: new URL("../assets/rich_leve23.png", import.meta.url).href,
        name: "一掷万金",
        level: "Lv23",
      },
      {
        min: 70000,
        max: 85000,
        url: new URL("../assets/rich_leve24.png", import.meta.url).href,
        name: "富甲一方",
        level: "Lv24",
      },
      {
        min: 85000,
        max: 100000,
        url: new URL("../assets/rich_leve25.png", import.meta.url).href,
        name: "财源滚滚",
        level: "Lv25",
      },
      {
        min: 100000,
        max: 200000,
        url: new URL("../assets/rich_leve26.png", import.meta.url).href,
        name: "金光闪耀",
        level: "Lv26",
      },
      {
        min: 200000,
        max: 300000,
        url: new URL("../assets/rich_leve27.png", import.meta.url).href,
        name: "挥霍无度",
        level: "Lv27",
      },
      {
        min: 300000,
        max: 400000,
        url: new URL("../assets/rich_leve28.png", import.meta.url).href,
        name: "富可敌国",
        level: "Lv28",
      },
      {
        min: 400000,
        max: 500000,
        url: new URL("../assets/rich_leve29.png", import.meta.url).href,
        name: "堆金积玉",
        level: "Lv29",
      },
      {
        min: 500000,
        max: 600000,
        url: new URL("../assets/rich_leve30.png", import.meta.url).href,
        name: "声势浩大",
        level: "Lv30",
      },
      {
        min: 600000,
        max: 1000000,
        url: new URL("../assets/rich_leve31.png", import.meta.url).href,
        name: "腰缠万贯",
        level: "Lv31",
      },
      {
        min: 1000000,
        max: 1400000,
        url: new URL("../assets/rich_leve32.png", import.meta.url).href,
        name: "金碧辉煌",
        level: "Lv32",
      },
      {
        min: 1400000,
        max: 1800000,
        url: new URL("../assets/rich_leve33.png", import.meta.url).href,
        name: "千金豪掷",
        level: "Lv33",
      },
      {
        min: 1800000,
        max: 2300000,
        url: new URL("../assets/rich_leve34.png", import.meta.url).href,
        name: "富贵荣华",
        level: "Lv34",
      },
      {
        min: 2300000,
        max: 2800000,
        url: new URL("../assets/rich_leve35.png", import.meta.url).href,
        name: "财倾天下",
        level: "Lv35",
      },
      {
        min: 2800000,
        max: 3500000,
        url: new URL("../assets/rich_leve36.png", import.meta.url).href,
        name: "家财万贯",
        level: "Lv36",
      },
      {
        min: 3500000,
        max: 4100000,
        url: new URL("../assets/rich_leve37.png", import.meta.url).href,
        name: "富丽堂皇",
        level: "Lv37",
      },
      {
        min: 4100000,
        max: 4700000,
        url: new URL("../assets/rich_leve38.png", import.meta.url).href,
        name: "金玉满堂",
        level: "Lv38",
      },
      {
        min: 4700000,
        max: 5300000,
        url: new URL("../assets/rich_leve39.png", import.meta.url).href,
        name: "富甲天下",
        level: "Lv39",
      },
      {
        min: 6000000,
        max: null,
        url: new URL("../assets/rich_leve40.png", import.meta.url).href,
        name: "豪掷乾坤",
        level: "Lv40",
      },
    ],
    leave2Arr: [
      {
        min: 0,
        max: 10,
        url: new URL("../assets/charm_leve1@2x.png", import.meta.url).href,
        name: "默默无闻",
        level: "Lv1",
      },
      {
        min: 10,
        max: 100,
        url: new URL("../assets/charm_leve2@2x.png", import.meta.url).href,
        name: "平淡无奇",
        level: "Lv2",
      },
      {
        min: 100,
        max: 300,
        url: new URL("../assets/charm_leve3@2x.png", import.meta.url).href,
        name: "乏善可陈",
        level: "Lv3",
      },
      {
        min: 300,
        max: 500,
        url: new URL("../assets/charm_leve4@2x.png", import.meta.url).href,
        name: "不为人知",
        level: "Lv4",
      },
      {
        min: 500,
        max: 800,
        url: new URL("../assets/charm_leve5@2x.png", import.meta.url).href,
        name: "孤芳自赏",
        level: "Lv5",
      },
      {
        min: 800,
        max: 10000,
        url: new URL("../assets/charm_leve6@2x.png", import.meta.url).href,
        name: "形单影只",
        level: "Lv6",
      },
      {
        min: 10000,
        max: 20000,
        url: new URL("../assets/charm_leve7@2x.png", import.meta.url).href,
        name: "门可罗雀",
        level: "Lv7",
      },
      {
        min: 20000,
        max: 30000,
        url: new URL("../assets/charm_leve8@2x.png", import.meta.url).href,
        name: "鲜为人知",
        level: "Lv8",
      },
      {
        min: 30000,
        max: 40000,
        url: new URL("../assets/charm_leve9@2x.png", import.meta.url).href,
        name: "无人问津",
        level: "Lv9",
      },
      {
        min: 40000,
        max: 50000,
        url: new URL("../assets/charm_leve10@2x.png", import.meta.url).href,
        name: "独来独往",
        level: "Lv10",
      },
      {
        min: 50000,
        max: 70000,
        url: new URL("../assets/charm_leve11@2x.png", import.meta.url).href,
        name: "小有名气",
        level: "Lv",
      },
      {
        min: 70000,
        max: 90000,
        url: new URL("../assets/charm_leve12@2x.png", import.meta.url).href,
        name: "略知一二",
        level: "Lv12",
      },
      {
        min: 90000,
        max: 110000,
        url: new URL("../assets/charm_leve13@2x.png", import.meta.url).href,
        name: "初露锋芒",
        level: "Lv13",
      },
      {
        min: 110000,
        max: 130000,
        url: new URL("../assets/charm_leve14@2x.png", import.meta.url).href,
        name: "稍有人缘",
        level: "Lv14",
      },
      {
        min: 130000,
        max: 150000,
        url: new URL("../assets/charm_leve15@2x.png", import.meta.url).href,
        name: "偶有人赞",
        level: "Lv15",
      },
      {
        min: 150000,
        max: 200000,
        url: new URL("../assets/charm_leve16@2x.png", import.meta.url).href,
        name: "渐入佳境",
        level: "Lv16",
      },
      {
        min: 200000,
        max: 250000,
        url: new URL("../assets/charm_leve17@2x.png", import.meta.url).href,
        name: "小有魅力",
        level: "Lv17",
      },
      {
        min: 250000,
        max: 300000,
        url: new URL("../assets/charm_leve18@2x.png", import.meta.url).href,
        name: "引人注目",
        level: "Lv18",
      },
      {
        min: 300000,
        max: 400000,
        url: new URL("../assets/charm_leve19@2x.png", import.meta.url).href,
        name: "颇受欢迎",
        level: "Lv19",
      },

      {
        min: 400000,
        max: 500000,
        url: new URL("../assets/charm_leve20@2x.png", import.meta.url).href,
        name: "广为人知",
        level: "Lv20",
      },

      {
        min: 500000,
        max: 600000,
        url: new URL("../assets/charm_leve21@2x.png", import.meta.url).href,
        name: "口碑载道",
        level: "Lv21",
      },
      {
        min: 600000,
        max: 700000,
        url: new URL("../assets/charm_leve22@2x.png", import.meta.url).href,
        name: "交口称赞",
        level: "Lv22",
      },
      {
        min: 700000,
        max: 800000,
        url: new URL("../assets/charm_leve23@2x.png", import.meta.url).href,
        name: "众星捧月",
        level: "Lv23",
      },
      {
        min: 800000,
        max: 900000,
        url: new URL("../assets/charm_leve24@2x.png", import.meta.url).href,
        name: "人见人爱",
        level: "Lv24",
      },
      {
        min: 900000,
        max: 1000000,
        url: new URL("../assets/charm_leve25@2x.png", import.meta.url).href,
        name: "风靡一时",
        level: "Lv25",
      },

      {
        min: 1000000,
        max: 1200000,
        url: new URL("../assets/charm_leve26@2x.png", import.meta.url).href,
        name: "风头正劲",
        level: "Lv26",
      },
      {
        min: 1200000,
        max: 1400000,
        url: new URL("../assets/charm_leve27@2x.png", import.meta.url).href,
        name: "炙手可热",
        level: "Lv27",
      },
      {
        min: 1400000,
        max: 1600000,
        url: new URL("../assets/charm_leve28@2x.png", import.meta.url).href,
        name: "如日中天",
        level: "Lv28",
      },
      {
        min: 1600000,
        max: 1800000,
        url: new URL("../assets/charm_leve29@2x.png", import.meta.url).href,
        name: "名扬四海",
        level: "Lv29",
      },
      {
        min: 1800000,
        max: 2000000,
        url: new URL("../assets/charm_leve30@2x.png", import.meta.url).href,
        name: "声名远播",
        level: "Lv30",
      },
      {
        min: 2000000,
        max: 2300000,
        url: new URL("../assets/charm_leve31@2x.png", import.meta.url).href,
        name: "家喻户晓",
        level: "Lv31",
      },
      {
        min: 2300000,
        max: 2600000,
        url: new URL("../assets/charm_leve32@2x.png", import.meta.url).href,
        name: "万人空巷",
        level: "Lv32",
      },
      {
        min: 2600000,
        max: 2900000,
        url: new URL("../assets/charm_leve33@2x.png", import.meta.url).href,
        name: "众望所归",
        level: "Lv33",
      },
      {
        min: 2900000,
        max: 3200000,
        url: new URL("../assets/charm_leve34@2x.png", import.meta.url).href,
        name: "一呼百应",
        level: "Lv34",
      },
      {
        min: 3200000,
        max: 3500000,
        url: new URL("../assets/charm_leve35@2x.png", import.meta.url).href,
        name: "趋之若鹜",
        level: "Lv35",
      },
      {
        min: 3500000,
        max: 4000000,
        url: new URL("../assets/charm_leve36@2x.png", import.meta.url).href,
        name: "红极一时",
        level: "Lv36",
      },
      {
        min: 4000000,
        max: 4500000,
        url: new URL("../assets/charm_leve37@2x.png", import.meta.url).href,
        name: "风华绝代",
        level: "Lv37",
      },
      {
        min: 4500000,
        max: 5000000,
        url: new URL("../assets/charm_leve38@2x.png", import.meta.url).href,
        name: "倾国倾城",
        level: "Lv38",
      },
      {
        min: 5000000,
        max: 5500000,
        url: new URL("../assets/charm_leve39@2x.png", import.meta.url).href,
        name: "举世瞩目",
        level: "Lv39",
      },
      {
        min: 6000000,
        max: null,
        url: new URL("../assets/charm_leve40@2x.png", import.meta.url).href,
        name: "万人景仰",
        level: "Lv40",
      },
    ],
  }),
  actions: {},
  getters: {
    getRichLevel: (state) => {
      return (playload) => {
        console.log("getRichLevel ------playload", playload);
        let arr = [];
        if (playload?.ty === "rich") {
          arr = state.leave1Arr;
        } else if (playload.ty === "charm") {
          arr = state.leave2Arr;
        }
        for (let i = 0; i < arr.length; i++) {
          if (
            arr[i].min <= Number(playload.val) ||
            (0 && (Number(playload.val) || 0 < arr[i].max))
          ) {
            return {
              name: arr[i].name,
              level: arr[i].level,
              url: arr[i].url,
            };
          }
          if (arr[i].max === "null") {
            return {
              name: arr[i].name,
              level: arr[i].level,
              url: arr[i].url,
            };
          }
        }
      };
    },

    richValImg1: (state) => {
      return (playload) => {
        let arr = [];
        if (playload.ty === "rich") {
          arr = state.leave1Arr;
        } else {
          arr = state.leave2Arr;
        }
        for (let i = 0; i < arr.length; i++) {
          let v = arr[i];
          if (v.min <= Number(playload.val) <= v.max) {
            let lv = "Lv0";
            switch (Number(playload.val)) {
              case 1 <= Number(playload) <= v.min:
                lv = "Lv1";
                break;
              case v.min < Number(playload) <= v.two:
                lv = "Lv2";
                break;
              case v.two < Number(playload) <= v.three:
                lv = "Lv3";
                break;
              case v.three < Number(playload) <= v.four:
                lv = "Lv4";
                break;
              case v.four < Number(playload) <= v.max:
                lv = "Lv5";
                break;
              default:
                lv = "Lv0";
                break;
            }
            return { url: v.url, lv, name: v.name };
          } else {
            return "";
          }
        }
      };
    },
    lv: (state) => {
      return (playload) => {
        let lv = "Lv0";
        switch (playload) {
          case 1 <= Number(playload) <= 1000:
            lv = "Lv1";
            break;
          case 1 <= Number(playload) <= 1000:
            lv = "Lv2";
            break;
          case 1 <= Number(playload) <= 1000:
            lv = "Lv3";
            break;
          case 1 <= Number(playload) <= 1000:
            lv = "Lv4";
            break;
          case 1 <= Number(playload) <= 1000:
            lv = "Lv5";
            break;

          default:
            lv = "Lv0";
            break;
        }
      };
    },
  },
});
export default useCounterStore;
